package com.zmx.piglearn.view

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View

class BlueDot(context: Context, set: AttributeSet) : View(context, set) {
    var _x = 50F
    var _y = 50F
    val paint = Paint()

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        paint.color = Color.BLUE
        canvas?.drawCircle(_x, _y, 30F, paint)
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        this._x = event?.x ?: 50F
        this._y = event?.y ?: 50F
        this.invalidate() // 通知组件进行重绘
        return true
    }
}